import java.util.List;
import java.util.Objects;
import java.util.function.Function;

public enum FuncEnum {
    EXCEL("EXCEL", ExcelFetcher::getNameList, "Excel表格"),
    MYSQL("MYSQL", MysqlFetcher::getNameList, "Mysql数据库"),
    SQLITE("SQLITE", SqliteFetcher::getNameList, "Sqlite数据库");
    
    private String type;
    private Function<String, List<String>> func;
    private String desc;
    
    FuncEnum(String type, Function<String, List<String>> func, String desc) {
        this.type = type;
        this.func = func;
        this.desc = desc;
    }
    
    public static Function<String, List<String>> getFuncByType(String type) {
        if (Objects.isNull(type)) {
            return null;
        }
        for (FuncEnum item : values()) {
            if (item.getType().equals(type)) {
                return item.getFunc();
            }
        }
        return null;
    }
    
    public String getType() {
        return type;
    }
    
    public Function<String, List<String>> getFunc() {
        return func;
    }
}